//引入样式
require("../../assets/css/normalize.css");
require("../../assets/css/common.css");
require("../../assets/css/reset.css");
require("../../assets/fonts/iconfont.css");
require("./sports_course_detail.less");

//引入模块
const axios = require("../../utils/axios.js");
const dom = require("../../utils/dom.js");

document.addEventListener("DOMContentLoaded", function () {
	//1. 获取地址栏传递的参数id
	let id = location.search.split("=").pop();

	axios.get("/api/train/courseDetail?id=" + id).then((res) => {
		//将视频数据存储到localStorage中
		console.log(res);
		let data = res.data.data.fragments;
		localStorage.setItem("fragments", JSON.stringify(data));
		// 详情页封面
		dom.get("#img").src = axios.defaults.baseURL + res.data.data.imgurl;
		dom.get("#title").textContent = res.data.data.name;
		dom.get("#calorie").textContent = res.data.data.calorie;
		dom.get("#time").textContent = res.data.data.time;
		dom.get("#peoplenum").textContent = res.data.data.peoplenum;
		dom.get(".sign").textContent = res.data.data.desc.slice(0, 48) + "...";
		dom.get("#frequency").textContent = res.data.data.frequency;
		dom.get("#instrument").textContent = res.data.data.instrument;
	});

	dom.get("#back").addEventListener("click", function () {
		history.back();
	});
});
